n = int(input())
d={}
for i in range(n):
    index,value=map(int,input().split())
    if index in d.keys():
        d[index]+=value
    else:
        d[index]=value
for index in sorted(d.keys()):
    print(index,d[index])
